package cn.edu.scau.cmi.zengGuanSheng.client;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;
import cn.edu.scau.cmi.zengGuanSheng.comprehensiveExperiment.MainClient;
import cn.edu.scau.cmi.zengGuanSheng.singleton.Chairman1;
import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

public class Chairman1Controller {
	@FXML
	private TextField tf_name;
	@FXML
	private TextArea textArea;
	@FXML
	private Button btn;
	@FXML
	private Button btn_return;

	// Event Listener on Button[#btn].onAction
	@FXML
	public void eventButton(ActionEvent event) {
		// TODO Autogenerated
		String name = tf_name.getText();
		if(Chairman1.getChairman1()==null) {
			Chairman1.getInstance(name);
			textArea.appendText(name+" 主席对象成功创建！"+"\r\n");
		}else {
			textArea.appendText(name+" 主席对象没有创建成功"+"，因为主席对象已经被创建，他是 "+Chairman1.getChairman1().getName()+"！\r\n");
		}
	}
	
	@FXML
	public void eventReturn(ActionEvent event) {
		Chairman1.setChairman1(null);
		MainClient main = new MainClient();
		main.start(Chairman1Client.primaryStage);
	}
}
